<?php
declare(strict_types=1);
namespace Field;

class QuestionThreadConst
{
    public const pk='ThreadID';
    public const index=['ThreadID'];
	public const fields=['ThreadID','CateID','Top','UserID','AttachID','UserIP','Subject','CreateAt','UpdateAt','Views','Posts','Images','Files','Mods','Closed','Fine','FirstPostID','LastUserID','LastPostID','Likes','Reward','IsSelf','Status'];
	public const comment=['ThreadID'=>'','CateID'=>'','Top'=>'','UserID'=>'','AttachID'=>'','UserIP'=>'','Subject'=>'','CreateAt'=>'','UpdateAt'=>'','Views'=>'','Posts'=>'','Images'=>'','Files'=>'','Mods'=>'版主操作次数，如果 > 0, 则查询 modlog，显示斑竹的评分','Closed'=>'已完结','Fine'=>'精华','FirstPostID'=>'首贴 pid','LastUserID'=>'最近参与的 uid','LastPostID'=>'最后回复的 pid','Likes'=>'点赞数','Reward'=>'悬赏','IsSelf'=>'1自己可见','Status'=>''];
	/*
    * @Field ThreadID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const ThreadID = 'ThreadID';
    /*
    * @Field CateID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const CateID = 'CateID';
    /*
    * @Field Top
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Top = 'Top';
    /*
    * @Field UserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UserID = 'UserID';
    /*
    * @Field AttachID
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const AttachID = 'AttachID';
    /*
    * @Field UserIP
    * @Type varchar(64)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UserIP = 'UserIP';
    /*
    * @Field Subject
    * @Type char(64)
    * @Collation utf8mb4_general_ci
    * @Null NO
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Subject = 'Subject';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field Views
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Views = 'Views';
    /*
    * @Field Posts
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Posts = 'Posts';
    /*
    * @Field Images
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Images = 'Images';
    /*
    * @Field Files
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Files = 'Files';
    /*
    * @Field Mods
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 版主操作次数，如果 > 0, 则查询 modlog，显示斑竹的评分
    */
    public const Mods = 'Mods';
    /*
    * @Field Closed
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 已完结
    */
    public const Closed = 'Closed';
    /*
    * @Field Fine
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 精华
    */
    public const Fine = 'Fine';
    /*
    * @Field FirstPostID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 首贴 pid
    */
    public const FirstPostID = 'FirstPostID';
    /*
    * @Field LastUserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 最近参与的 uid
    */
    public const LastUserID = 'LastUserID';
    /*
    * @Field LastPostID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 最后回复的 pid
    */
    public const LastPostID = 'LastPostID';
    /*
    * @Field Likes
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 点赞数
    */
    public const Likes = 'Likes';
    /*
    * @Field Reward
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 悬赏
    */
    public const Reward = 'Reward';
    /*
    * @Field IsSelf
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 1自己可见
    */
    public const IsSelf = 'IsSelf';
    /*
    * @Field Status
    * @Type int(11)
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 
    */
    public const Status = 'Status';
}

class QuestionThreadColumns
{
public  int $ThreadID;
   public  int $CateID=0;
   public  int $Top=0;
   public  int $UserID=0;
   public  int $AttachID=0;
   public  ?string $UserIP='';
   public  string $Subject;
   public  ?string $CreateAt='';
   public  ?string $UpdateAt='';
   public  int $Views=0;
   public  int $Posts=0;
   public  int $Images=0;
   public  int $Files=0;
   public  int $Mods=0;
   public  int $Closed=0;
   public  int $Fine=0;
   public  int $FirstPostID=0;
   public  int $LastUserID=0;
   public  int $LastPostID=0;
   public  int $Likes=0;
   public  int $Reward=0;
   public  int $IsSelf=0;
   public  int $Status=0;
	public function toArray():array
	{
		return [
'ThreadID'=>$this->ThreadID,
    'CateID'=>$this->CateID,
    'Top'=>$this->Top,
    'UserID'=>$this->UserID,
    'AttachID'=>$this->AttachID,
    'UserIP'=>$this->UserIP,
    'Subject'=>$this->Subject,
    'CreateAt'=>$this->CreateAt,
    'UpdateAt'=>$this->UpdateAt,
    'Views'=>$this->Views,
    'Posts'=>$this->Posts,
    'Images'=>$this->Images,
    'Files'=>$this->Files,
    'Mods'=>$this->Mods,
    'Closed'=>$this->Closed,
    'Fine'=>$this->Fine,
    'FirstPostID'=>$this->FirstPostID,
    'LastUserID'=>$this->LastUserID,
    'LastPostID'=>$this->LastPostID,
    'Likes'=>$this->Likes,
    'Reward'=>$this->Reward,
    'IsSelf'=>$this->IsSelf,
    'Status'=>$this->Status,        ];
	}
}

class QuestionThreadRow
{
	public QuestionThreadColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'ThreadID' => $this->data->ThreadID,
        'CateID' => $this->data->CateID,
        'Top' => $this->data->Top,
        'UserID' => $this->data->UserID,
        'AttachID' => $this->data->AttachID,
        'UserIP' => $this->data->UserIP,
        'Subject' => $this->data->Subject,
        'CreateAt' => $this->data->CreateAt,
        'UpdateAt' => $this->data->UpdateAt,
        'Views' => $this->data->Views,
        'Posts' => $this->data->Posts,
        'Images' => $this->data->Images,
        'Files' => $this->data->Files,
        'Mods' => $this->data->Mods,
        'Closed' => $this->data->Closed,
        'Fine' => $this->data->Fine,
        'FirstPostID' => $this->data->FirstPostID,
        'LastUserID' => $this->data->LastUserID,
        'LastPostID' => $this->data->LastPostID,
        'Likes' => $this->data->Likes,
        'Reward' => $this->data->Reward,
        'IsSelf' => $this->data->IsSelf,
        'Status' => $this->data->Status, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new QuestionThreadColumns();
        isset($data['ThreadID']) && $this->data->ThreadID = (int)$data['ThreadID'];
           isset($data['CateID']) && $this->data->CateID = (int)$data['CateID'];
           isset($data['Top']) && $this->data->Top = (int)$data['Top'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['AttachID']) && $this->data->AttachID = (int)$data['AttachID'];
           isset($data['UserIP']) && $this->data->UserIP = (string)$data['UserIP'];
           isset($data['Subject']) && $this->data->Subject = (string)$data['Subject'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['Views']) && $this->data->Views = (int)$data['Views'];
           isset($data['Posts']) && $this->data->Posts = (int)$data['Posts'];
           isset($data['Images']) && $this->data->Images = (int)$data['Images'];
           isset($data['Files']) && $this->data->Files = (int)$data['Files'];
           isset($data['Mods']) && $this->data->Mods = (int)$data['Mods'];
           isset($data['Closed']) && $this->data->Closed = (int)$data['Closed'];
           isset($data['Fine']) && $this->data->Fine = (int)$data['Fine'];
           isset($data['FirstPostID']) && $this->data->FirstPostID = (int)$data['FirstPostID'];
           isset($data['LastUserID']) && $this->data->LastUserID = (int)$data['LastUserID'];
           isset($data['LastPostID']) && $this->data->LastPostID = (int)$data['LastPostID'];
           isset($data['Likes']) && $this->data->Likes = (int)$data['Likes'];
           isset($data['Reward']) && $this->data->Reward = (int)$data['Reward'];
           isset($data['IsSelf']) && $this->data->IsSelf = (int)$data['IsSelf'];
           isset($data['Status']) && $this->data->Status = (int)$data['Status'];
    }
}
?>